import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';

export default function createElementPlusPlugin() {
  return [
    AutoImport({
      resolvers: [ElementPlusResolver(), IconsResolver({})],
      dts: 'types/auto-imports.d.ts',
    }),
    Components({
      resolvers: [
        ElementPlusResolver(),
        IconsResolver({ enabledCollections: ['ep'] }),
      ],
      dirs: ['src/components', 'src/**/components'],
      dts: 'types/components.d.ts',
    }),
    Icons({
      autoInstall: true,
    }),
  ];
}
